home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 8520 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.2 KB  |  32 lines

  1. Newsgroups: comp.lang.pascal.misc,comp.lang.c++,comp.lang.c,comp.lang.pascal.borland
  2. Path: in2.uu.net!allegra!alice!ark
  3. From: ark@research.att.com (Andrew Koenig)
  4. Subject: Re: Tough FACTORIAL math problem...
  5. Message-ID: <DMruKv.CCp@research.att.com>
  6. Organization: AT&T Research, Murray Hill NJ
  7. References: <4fr8be$ass@news.iconn.net>
  8. Date: Wed, 14 Feb 1996 15:19:43 GMT
  9.  
  10. In article <4fr8be$ass@news.iconn.net> thecrow@iconn.net (The Crow) writes:
  11.  
  12. > Here is what I am trying to do, I want to find the last NON-ZERO digit of a 
  13. > given factorial.  For instance,
  14.  
  15. > 5! = 120
  16.  
  17. > so the last non-zero digit is 2.  I want to be able to do this up to 1000.  
  18. > Problem is, no matter how huge of a data-type you use, there isn't any way for 
  19. > the computer to handle 1000!,
  20.  
  21. Sure there is.  Lots of people have written programs to do
  22. arbitrary-precision integer arithmetic.
  23.  
  24. But a few minutes of thought convinced me that the problem
  25. you pose can be solved very easily, without arbitrary precision
  26. arithmetic.  I would tell you how to do it, but the problem
  27. looks like a homework assignment and I don't want to contribute
  28. to academic plagiarism.
  29. -- 
  30.                 --Andrew Koenig
  31.                   ark@research.att.com
  32.